package com.zens.cms.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zens.cms.entity.Article;
import com.zens.cms.entity.ArticleExample;
import com.zens.cms.entity.ArticleWithBLOBs;
import com.zens.cms.entity.Articlegroup;
import com.zens.cms.entity.ArticlegroupExample;
import com.zens.cms.entity.ArticlegroupExample.Criteria;
import com.zens.cms.entity.TColumn;
import com.zens.cms.entity.TColumnExample;
import com.zens.cms.mapper.ArticleMapper;
import com.zens.cms.mapper.ArticlegroupMapper;
import com.zens.cms.mapper.TColumnMapper;
import com.zens.cms.services.IArticleGroupTemp;

@Service
public class ArticleGroupImplTemp implements IArticleGroupTemp {
	
	@Resource
	ArticlegroupMapper mapper;
	@Resource
	ArticleMapper articleMapper;
	@Resource
	TColumnMapper columnMapper;

	@Override
	public List<Articlegroup> getArticleGroupListByCidList(List<Long> idList) {
		ArticlegroupExample ae = new ArticlegroupExample();
		Criteria ac = ae.createCriteria();
		ac.andFcolumnidIn(idList);
		return mapper.selectByExample(ae);
	}

	@Override
	public List<Article> getHomePageArtcleDataByIdList(
			List<Long> idList) {
		ArticleExample ae = new ArticleExample();
		com.zens.cms.entity.ArticleExample.Criteria ac = ae.createCriteria();
		ac.andIdIn(idList);
		return articleMapper.selectByExample(ae);
	}

	@Override
	public List<TColumn> getBrothersColList(TColumn column) {
		TColumnExample te = new TColumnExample();
		com.zens.cms.entity.TColumnExample.Criteria tc = te.createCriteria();
		tc.andFcolumngpEqualTo(column.getFcolumngp());
		tc.andFcolumnlevelEqualTo(column.getFcolumnlevel());
		tc.andIdNotEqualTo(column.getId());
		return columnMapper.selectByExample(te);
	}

	@Override
	public TColumn getTColumnEntityByName(String name) {
		TColumnExample e = new TColumnExample();
		com.zens.cms.entity.TColumnExample.Criteria c = e.createCriteria();
		c.andFcolumnnameEqualTo(name);
		List<TColumn> list = columnMapper.selectByExample(e);
		return list.isEmpty()?null:list.get(0);
	}

}
